﻿/*
 * Copyright 2014, 2015 Dominick Baier, Brock Allen
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

using IdentityServer3.Core;
using IdentityServer3.Core.Models;
using System.Collections.Generic;

namespace IdentityServer3.Tests.Endpoints
{
    public class TestClients
    {
        public static List<Client> Get()
        {
            return new List<Client>
            {
                new Client
                {
                    ClientName = "Code Flow Clients",
                    Enabled = true,
                    ClientId = "codeclient",
                    ClientSecrets = new List<Secret>
                    { 
                        new Secret("secret".Sha256())
                    },

                    Flow = Flows.AuthorizationCode,
                    
                    RequireConsent = true,
                    AllowRememberConsent = true,
                    
                    ClientUri = "https://identityserver.io",
                    LogoUri = "",
                    
                    RedirectUris = new List<string>
                    {
                        // MVC code client with module
                        "https://localhost:44320/oidccallback",
                        
                        // MVC code client manual
                        "https://localhost:44312/callback",
                    },
                    
                    AllowedScopes = new List<string>
                    { 
                        Constants.StandardScopes.OpenId,
                        Constants.StandardScopes.Profile,
                        Constants.StandardScopes.Email,
                        "read",
                        "write"
                    },

                    AccessTokenType = AccessTokenType.Reference,
                    
                    IdentityTokenLifetime = 360,
                    AccessTokenLifetime = 360,
                    AuthorizationCodeLifetime = 120
                },

                new Client
                {
                    ClientName = "Implicit Clients",
                    Enabled = true,
                    ClientId = "implicitclient",
                    ClientSecrets = new List<Secret>
                    { 
                        new Secret("secret".Sha256())
                    },
                    
                    Flow = Flows.Implicit,
                    AllowAccessTokensViaBrowser = true,
                    
                    ClientUri = "https://identityserver.io",
                    LogoUri = "",

                    RequireConsent = true,
                    AllowRememberConsent = true,
                    
                    RedirectUris = new List<string>
                    {
                        // WPF client
                        "oob://localhost/wpfclient",
                        
                        // JavaScript client
                        "http://localhost:21575/index.html",

                        // MVC form post sample
                        "http://localhost:11716/account/signInCallback",

                        // OWIN middleware client
                        "http://localhost:2671/",
                    },
                    
                    AllowedScopes = new List<string>
                    { 
                        Constants.StandardScopes.OpenId,
                        Constants.StandardScopes.Profile,
                        Constants.StandardScopes.Email,
                        "read",
                        "write"
                    },

                    AccessTokenType = AccessTokenType.Jwt,
                    
                    IdentityTokenLifetime = 360,
                    AccessTokenLifetime = 360,
                },
                new Client
                {
                    ClientName = "Client Credentials Flow Client",
                    Enabled = true,
                    ClientId = "client",
                    ClientSecrets = new List<Secret>
                    { 
                        new Secret("secret".Sha256())
                    },

                    Flow = Flows.ClientCredentials,
                    
                    AllowedScopes = new List<string>
                    { 
                        "read",
                        "write"
                    },

                    AccessTokenType = AccessTokenType.Jwt,
                    AccessTokenLifetime = 360,
                },
                new Client
                {
                    ClientName = "Resource Owner Flow Client",
                    Enabled = true,
                    ClientId = "roclient",
                    ClientSecrets = new List<Secret>
                    { 
                        new Secret("secret".Sha256())
                    },

                    Flow = Flows.ResourceOwner,
                    
                    AllowedScopes = new List<string>
                    { 
                        "read",
                        "write"
                    },

                    AccessTokenType = AccessTokenType.Jwt,
                    AccessTokenLifetime = 360,
                },
                new Client
                {
                    ClientName = "Code Flow Clients (NoExternal)",
                    Enabled = true,
                    ClientId = "no_external_idps",
                    ClientSecrets = new List<Secret>
                    { 
                        new Secret("secret".Sha256())
                    },

                    Flow = Flows.AuthorizationCode,
                    IdentityProviderRestrictions = new List<string>{"NotGoogle"},
                    
                    RequireConsent = true,
                    AllowRememberConsent = true,
                    
                    ClientUri = "https://identityserver.io",
                    LogoUri = "",
                    
                    RedirectUris = new List<string>
                    {
                        // MVC code client with module
                        "https://localhost:44320/oidccallback",
                        
                        // MVC code client manual
                        "https://localhost:44312/callback",
                    },
                    
                    AllowedScopes = new List<string>
                    { 
                        Constants.StandardScopes.OpenId,
                        Constants.StandardScopes.Profile,
                        Constants.StandardScopes.Email,
                        "read",
                        "write"
                    },
                    
                    AccessTokenType = AccessTokenType.Reference,
                    
                    IdentityTokenLifetime = 360,
                    AccessTokenLifetime = 360,
                    AuthorizationCodeLifetime = 120
                },
                new Client
                {
                    ClientName = "Code Flow Clients (NoExternal)",
                    Enabled = true,
                    ClientId = "any_external_idps",
                    ClientSecrets = new List<Secret>
                    { 
                        new Secret("secret".Sha256())
                    },

                    Flow = Flows.AuthorizationCode,
                    IdentityProviderRestrictions = new List<string> {},
                    
                    RequireConsent = true,
                    AllowRememberConsent = true,
                    
                    ClientUri = "https://identityserver.io",
                    LogoUri = "",
                    
                    RedirectUris = new List<string>
                    {
                        // MVC code client with module
                        "https://localhost:44320/oidccallback",
                        
                        // MVC code client manual
                        "https://localhost:44312/callback",
                    },
                    
                    AllowedScopes = new List<string>
                    { 
                        Constants.StandardScopes.OpenId,
                        Constants.StandardScopes.Profile,
                        Constants.StandardScopes.Email,
                        "read",
                        "write"
                    },

                    AccessTokenType = AccessTokenType.Reference,
                    
                    IdentityTokenLifetime = 360,
                    AccessTokenLifetime = 360,
                    AuthorizationCodeLifetime = 120
                },
            };
        }
    }
}